using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BUS;
using Utility;
using Entities;

public partial class Admin_Suadiadiem : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
            loaddropdownlist();
        }
    }
    private void loaddropdownlist()
    {
        dr_tenm.DataSource = tbMienBUS.GetAll();
        dr_tenm.DataTextField = tbMiencolumn.tenmien.ToString();
        dr_tenm.DataValueField = tbMiencolumn.mamien.ToString();
        dr_tenm.DataBind();
        dr_tenm.Items.Insert(0, new ListItem("All", "0"));
    }
    protected void btn_sua_Click(object sender, EventArgs e)
    {
        //try
        //{
        int id = int.Parse(Request.QueryString["id"].ToString());
        tbDiadiem ddiem = tbDiadiemBUS.GetByID(id);
        //tbDiadiem ddiem = new tbDiadiem();
        ddiem.Mamien = int.Parse(dr_tenm.SelectedValue);
        ddiem .Tendiadiem  = txt_tendd.Text;
        tbDiadiemBUS .Update(ddiem );

        //catch
        //{
        Response.Redirect("~/Admin/Danhsachdiadiem.aspx");
        //}
    }
    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            txt_madd.Text = id.ToString();

            tbDiadiem  dd = tbDiadiemBUS .GetByID(id);
            dr_tenm.SelectedValue = dd.Mamien.ToString();
            txt_tendd.Text = dd.Tendiadiem ;
        }
        catch
        {
            Response.Redirect("~/Admin/Danhsachdiadiem.aspx");
        }
    }
}
